﻿using EFCoreBooks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace 多层项目中EFCore的使用.Controllers
{
  [Route("api/[controller]/[action]")]
  [ApiController]
  public class TestController : ControllerBase
  {
    private readonly MyDbContext dbContext;

    public TestController(MyDbContext dbContext)
    {
      this.dbContext = dbContext;
    }

    [HttpGet]
    public string Get1()
    {
      return dbContext.Books.FirstOrDefault().ToString(); ;
    }
  }
}
